var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = cc._decorator,
    i = a.ccclass,
    s = (a.property, a.menu),
    c = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.setdata = function (t, e, o) {
                (this.list = t),
                    (this.index = e),
                    (this.data = o),
                    (this.item_active = !1),
                    this.list.scrollView.vertical ? (this.checkOut = this.checkOutY) : (this.checkOut = this.checkOutX);
            }),
            (e.prototype.onEnable = function () {
                this.list.content.on(cc.Node.EventType.POSITION_CHANGED, this.checkOut, this),
                    this.node.on(cc.Node.EventType.POSITION_CHANGED, this.checkOut, this);
            }),
            (e.prototype.checkOut = function () {
                console.log("checkOut");
            }),
            (e.prototype.setActive = function (t) {
                if (this.item_active != t)
                    if (((this.item_active = t), t)) {
                        var e = this.list.getNode();
                        this.list.setNode(this, e), this.node.addChild(e);
                    } else {
                        e = this.node.children[0];
                        this.list.returnNode(e);
                    }
            }),
            (e.prototype.checkOutX = function () {
                var t = this.list.node.width / 2,
                    e = this.node.x + this.node.parent.x - this.node.width / 2;
                if (e > t) this.setActive(!1);
                else {
                    var o = -t;
                    e + this.node.width < o ? this.setActive(!1) : this.setActive(!0);
                }
            }),
            (e.prototype.checkOutY = function () {
                var t = this.list.node.height / 2,
                    e = this.node.y + this.node.parent.y - this.node.height / 2;
                if (e > t) this.setActive(!1);
                else {
                    var o = -t;
                    e + this.node.height < o ? this.setActive(!1) : this.setActive(!0);
                }
            }),
            (e.prototype.onDisable = function () {
                this.list.content.off(cc.Node.EventType.POSITION_CHANGED, this.checkOut, this),
                    this.node.off(cc.Node.EventType.POSITION_CHANGED, this.checkOut, this);
                var t = this.node.children[0];
                t && this.list.returnNode(t);
            }),
            (e.prototype.refresh = function () {
                if (this.item_active) {
                    var t = this.node.children[0];
                    this.list.setNode(this, t);
                }
            }),
            (e = r([i, s("列表/Item")], e))
        );
    })(cc.Component);
o.default = c;
